[P132] Additional support for INA226, INA228, INA230, INA231 and INA260#5462
[P132] Additional support for INA226, INA228, INA230, INA231 and INA260#5462tonhuisman wants to merge 17 commits intoletscontrolit:megafrom
Conversation
|
Great job, thank you very much, I'm interested in INA228 support myself. Will there be binaries available for download for the ESP32? |
Assuming you mean ESP32-Classic, here are the builds that this plugin is included in: ESP_Easy_mega_20251228_energy_ESP32_4M316k-2.zip for ESP32 with 4MB Flash Both include the OTA Edit: Re-uploaded the zip files (appended NB: Possibly the INA228 Power setting might not return the expected result, as the code shows a TODO there... 🤔 |
|
Thanks for the binaries. I loaded the 4M316k.factory module, and it boots up, but I doubt it will work correctly. There's no option to select the shunt value. Without checking the documentation, I'm not entirely sure if all the INA3221/INA226/INA228/INA231/INA260 models have the same registers. At first glance, the INA3221 is a 3-channel model, while the others aren't. So how would this work without selecting the INA model in the plugin? |
Not sure what/how you installed the binary, but the P132 plugin ("Energy (DC) - INA3221/INA226/INA228/INA231/INA260") should show an |
|
Ah, this is a phenomenon we sometimes see when some other firmware (ESPHome, Espruna, Tasmota?) has been used on the esp, and the flash hasn't been wiped before installing ESPEasy. It tries to re-use an existing file system, but if that's too small it fails in writing the configuration file(s), causing weird behavior and/or crashed like you have shown. |
|
Thank you again for your involvement and willingness to help. It's possible this is a hardware issue with my ESP32; none of the methods I know of for clearing the memory have yielded positive results. Since I only have one ESP32 board (I have many, but they're ESP8266s), I've ordered another ESP32, but it will probably take some time for them to arrive. |
I've built you a Custom Energy build with this feature enabled for ESP8266 with 4MB Flash: |
|
Another huge thank you. The ESP8266 binary is better. Almost everything seems to work, but there's a problem with reading data. Admittedly, I've been experimenting with the INA226 for a while now. I have a question: instead of selecting the internal resistor value, there should be an option to select a shunt, e.g., 30A (75mV), etc., because these built-in resistors are intended for small pads. |
|
Selecting a different shunt resistor is mostly a wiring issue, finding the right shunt value (for 30A the 2 mOhm setting should be just right for an INA226), find a 0.002 Ohm resistor that can handle the power dissipation, remove the existing shunt from the board and wire the new shunt to the board. |
|
I don't care about such currents, but this connector allows you to select a current in the range [1-1022 A], but there's still no option to change the shunt, and that's where I see a lack of consistency. A while ago, a similar build for the ESP8266 and INA226 was posted on the forum, with the option to change the shunt to an external one. Again, I don't care about that. |
|
I was referring to shunts like these, of course, for larger currents. Because looking for a resistor for, say, 50A is a bad idea. |
|
Those shunts are for 75mV. Some of the INA chips, like INA219 and INA228, can handle higher shunt voltages, up to 320mV for INA219, and 160mV (fixed) for INA228. But that would still work fine, would just be a resolution-related issue. |
Well, I can limit that max. value to, say, 30A, I just added the max current setting as it is required for the new library I'm using. |
|
These currents don't bother me at all, so they can stay as they are. |
|
I've changed the resolution for the Shunt setting, and added more options for high-current shunts, to better match those to the Max. current setting. |
|
I don't have a shunt at home because I don't measure such high currents. I downloaded your binary; in my opinion, it offers much more options. I'll get myself a shunt, let's say the smallest one, and run some tests. Thanks again. |
|
#2622 This is an old link from November 18, 2021. Your request for the source code is also in this thread. |
|
I have used the Zanduino INA library for adding support for the extra INAxxx models, though I haven't compared notes with the wollewald (INA226 explicit) library, as it is quite different. What did you use for |
|
Averaging samples: I tested probably all of them from this list, the closest current readings gave a value of 16. Conversion rate Current: I also tested all values from the selection list, here the closest current consumption readings give a value of 1. Despite all this, the current measurement is unstable and significantly different from the actual one. |
|
Where do you have the shunt? At the GND level or at the + side? In the datasheet on page 14, there is some suggestion of filtering. I'm discussing the code with Ton (via Signal) right now and we already found a few things that can be improved in the code. |
|
Also what current are you trying to measure? I noticed a few places in the code of the library where quite a bit of resolution is lost due to careless calculations or completely illogical stripping of bits. |
|
I can't reach the home-garden.org site from my location (time-out), not sure if it still is available, or blocked for some reason, so there is no source-code available for comparison. |
|
Ok. I'll check with the filtering system. Another question: Has anyone else tested the INA226 with your input? |
|
I tested with the on-board shunt and a quite low current. Haven't payed much attention to stable output, other than it stayed constant, as was to be expected, and changed when I changed the 'load'. |
|
I'm personally not a fan of measuring current on the 'high side', but it should work as the voltage doesn't exceed the max. input of the INA226. There are lots of reasons why the other binary file yielded more stable results. Apart from this, there are still some parts of the code that can be optimized as quite a lot of resolution can be lost how it is done right now. |
|
Hello friends, you can add "ESP_Easy_mega_20251228_energy_ESP32_4M316k"RTC DS3231 and TFT LCD _P095_ILI9341 to the firmware, or tell me where to download the plugin with support for INA3231, INA226, etc., to try to build the firmware yourself. |
|
We have documentation on how to set up a local development environment here. It is mostly describing how to develop a new plugin or feature, but also briefly explains how to build a Custom ESPEasy, containing exactly the plugins and features you want to use. A much simpler solution, btw, is to get an ESP32 board with 8MB or 16MB of flash (ESP32 Classic, ESP32-S3, ESP32-C3 or ESP32-C6), and install one of the MAX builds that includes (nearly) all features and plugins. |
|
Hi, thanks for the link. And where can I download the max firmware? I didn't come across any, or I was looking in the wrong place. |
|
"tonhuisman" thank you for guiding me in the right direction, found the MAX firmware on your MAX forum, soldered the flash drive on my ESP32 Wroom to a 16M flash drive, filled in the firmware and everything worked. |
Not sure what you're talking about here, but official Release builds are available from our Github Releases page (for flashing via a local tool) or from the WebFlasher at https://TD-er.nl/ESPEasy, |
|
@Gonzol999 Here's a fresh build for you to test, it has the calculation improvement, mentioned above, and also checks if a measurement result is available before retrieving it, for improved stability of results. NB: This build is based on the 20260108 release, without the hotfix that was released today, as it's a test build. It will be updated to the |
|
The current readings are stable but unrealistic. I'm testing a current of about 3 A, and the ESP with the current load shows 2732.02 A. |
|
Hmm sounds like a mixup of mA and uA somewhere. (or mV vs uV) |
|
Have you tested this yourself, or has anyone else done it? Maybe the problem is how I do it. |
It's not obvious from either the configuration or the documentation, but this plugin shows the Current values in
The actual current to measure doesn't have to match the capacity of the shunt, then only a part of the 75mV output is being used. |
|
Thanks for the replies. If the plugin is supposed to return measurement results in mA, then it's probably OK. Yesterday, I solved the problem with the formula, dividing the measured value by 1000. You've clarified my doubts about the measurement range selection field. I'll continue testing your results with other settings. |
|
Do you have other chips which are also supported by this plugin? Ton did move quite a lot of code around, so it is possible something got overlooked. |
|
I already have an INA228 at home, but I'm still waiting for the ESP32 from AliExpress. Testing would need to be done on the ESP32. For testing, I need to build a receiver with a more stable current source, preferably a resistor, because as you mentioned earlier, a UPS isn't the best receiver for such tests. But I can still test. |
|
Hello everyone. I started testing the INA228 plug-in today, still with a low voltage of around 14V and a very low current of around 0.2A. The voltage measurements are OK, but the current is significantly off. The value measured by the plug-in fluctuates between 1.86 and 5.37mA. If, as Ton wrote earlier, the plug-in returns a value in mA, this result is outrageous. The board has a standard shunt resistor of 0.002Ω, and I have the Max. Current set to the lowest range, which is 1A. I noticed another problem: in the Tools/Interfaces tab, there's an I2C Scan tool. The Supported Devices field should indicate which module was found on the bus, but it's blank. The same is true for the INA226, so it's probably the plug-in's fault. One more question: INA228 modules have GPIO alerts. Do you plan to support this feature in the plug-in? |
Hm, that's somewhat unexpected. I recently (today) received an INA228. I'll hook that up and see what results I can achieve.
Depending on the build, many known device names are included. For ESP8266 builds these names are not included for space reasons.
That's currently not planned. |
With our voltages, the discrepancies and instability in the reading are similar. It's possible that my INA228 board is of poor quality. How are your tests?
This is not a problem, the found module address is returned and if someone connects the module to the I2C bus, they probably know what they are connecting
this is also not a problem, similar functionality can be achieved using rules and e.g. the ESP GPIO port |





Resolves #2622
Resolves #2602
Forum request: https://www.letscontrolit.com/forum/viewtopic.php?t=10746
Forum request: https://www.letscontrolit.com/forum/viewtopic.php?p=74843
Features:
TODO: